package com.ltkj.common.core.utils;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author gushaoliang
 * @Date 2023/8/31 14:12
 * @PackageName:com.ltkj.common.core.utils
 * @ClassName: ListUtiles
 * @Description: TODO
 * @Version 1.0
 */
public class ListUtiles {


    public static List dealData(List target, int size) {

        List threadList = new ArrayList();
        // 获取被拆分的数组个数
        int arrSize = target.size() % size == 0 ? target.size() / size : target.size() / size + 1;
        for (int i = 0; i < arrSize; i++) {
            List students = new ArrayList();
            // 把指定索引数据放入到list中
            for (int j = i * size; j <= size * (i + 1) - 1; j++) {

                if (j <= target.size() - 1) {
                    students.add(target.get(j));
                }
            }
            threadList.add(students);
        }

        return threadList;

    }
}